package anzeigeElemente;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.main.verkehrsinfo.R;

public class TextProgressBar extends RelativeLayout {

	TextView text;
	ProgressBar bar;

	public TextProgressBar(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		konfiguriereBalken();
	}

	public TextProgressBar(Context context, AttributeSet attrs) {
		super(context, attrs);
		konfiguriereBalken();
	}

	public TextProgressBar(Context context) {
		super(context);
		konfiguriereBalken();
	}

	/**
	 * Initialisiert alle wichtigen Attribute.
	 */
	private void konfiguriereBalken() {
		addView(inflate(getContext(), R.layout.text_progressbar_layout, null));
		text = (TextView) findViewById(R.id.notification_title_text);
		bar = (ProgressBar) findViewById(R.id.progress_bar);
		this.setPadding(3, 5, 3, 5);
	}

	/**
	 * Setzt den Fortschritt des Balkens, sowie den den Fortschritt des Balkens
	 * in Textform.
	 * 
	 * @param progress
	 *            der Fortschritt
	 */
	public void setProgress(int progress) {
		bar.setProgress(progress);
		text.setText(Integer.toString(progress) + "%");

		// bar.setProgressDrawable(getResources().getDrawable(
		// R.drawable.progress_bar_background));
	}
}
